<!-- 大小额贷记退汇查询 -->
<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
      :labelWidth="75"
    >
      <template slot="endSlotOption">
        <amount-range-search label="金额区间" ref="amountRangeSearch"></amount-range-search>
      </template>
    </ht-search-form>
    <ht-table
      ref="dataTable"
      rowKey="id"
      :initData="true"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    toViewDetail(scope.row);
                  },
                }
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <query-detail-dialog ref="queryDetailDialog" :dictMap="dictMap"></query-detail-dialog>
  </div>
</template>
<script>

import { apiUrlConfig } from "@/api/cnaps/baseBiz/return/inquire/index";
import QueryDetailDialog from "./components/Details";
import { listPageMixin } from "@/libs/listPageMixin";
import AmountRangeSearch from "@/views/components/AmountSearchInput";
export default {
  name: "baseBizReturnInquireIndex",
  mixins: [listPageMixin],
  components: {
    AmountRangeSearch,
    QueryDetailDialog,
  },
  data() {
    return {
      dictMap: {},
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: [
        "TXN_STATUS",
        "Cnaps2Dict.SYS_CODE",
        "Cpg.Branch",
        "PRIORITY3CODE",
        "PROCESSSTATUS",
        "PKG_STATUS",
        "Cnaps2Dict.CP2_BRNO",


      ],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        idSeqno:'',
        oIdSeqno:'',
        brno:'',
        cpgdate:'',
        cpgdate2:'',
        workdate:'',
        workdate2:'',
        amount1: '',
        amount2: '',
      },
      formOptions: [],
      tableBindColumns: [
        { label: `交易流水号`, prop: "id", width: "160" },
        { label: `内部机构号`, prop: "brno",dictCode: "Cnaps2Dict.CP2_BRNO", width: "160" },
        { label: `愿交易流水号`, prop: "oriId", width: "160" },
        { label: `来往标识`, prop: "drct", dictCode: "DRCTCODE", width: "160" },
        { label: `CPG日期`, prop: "cpgdate", sortable: false, width: 160 },
        { label: `工作日期`, prop: "workdate", sortable: false, width: 160 },
        { label: `付款行行号`, prop: "payerBrno", width: 200 },
        { label: `付款人名称`, prop: "payerName", width: 200 },
        { label: `收款行行号`, prop: "payeeBrno", width: 200 },
        { label: `收款人名称`, prop: "payeeName", width: 200 },
        { label: `金额`, prop: "amount", width: 160, type: "price", sortable: false },
        { label: `中心状态`, prop: "pbocStatus", sortable: false,
          dictCode: "PROCESSSTATUS", }
      ],
    };
  },
  watch: {

  },
  mounted() {
    this.$refs.amountRangeSearch.$on('getAmountRange',this.beforeSearchCallback);

    this.formOptions = [
      {
        type: "input",
        prop: "idSeqno",
        defaultAttr: {
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "input",
        prop: "oIdSeqno",
        defaultAttr: {
          label: "原流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dict",
        prop: "brno",
        dict: "Cpg.Branch",
        defaultAttr: {
          radio: false,
          linkParentChoose: false,
          label: "分行选择",
          placeholder: "请选择分行",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      }
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.amount1 = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      let that = this;
      return new Promise(function (resolve, reject) {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount1 = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      console.log("editComplete", state);
      if (state == true) {
        this.getList();
      }
    },
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /*查看明细*/
    toViewDetail(row) {
      this.$refs.queryDetailDialog.show(row.id);
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
